clear all;  addpath('auxiliar'); addpath('Simulated_Datasets');load SIMULATION_ERGODIC_DE
mean_ind=20;
bg=1;
shoc=25;
figure
Dlim=KAPYT./q_big;
YSIM=priceSIM+ySIM;
mY=mean(YSIM);

%yyaxis left
plot(bgrid(bg,:)/mY,squeeze(bp(bg,:,shoc,bg))/mY,'Linewidth',2,'Color','b','LineStyle','-'); hold on;
plot(bgrid(bg,:)/mY,squeeze(Dlim(bg,:,shoc,bg))/mY,'Linewidth',2,'Color','k','LineStyle',':'); hold on;
plot(bgrid(bg,:)/mY,bgrid(bg,:)/mY,'Linewidth',2,'Color','k','LineStyle','-','Marker','none');hold on;legend boxoff;
ylim([0 .6]);
ylabel('Percent of output','Interpreter','Latex'); legend boxoff;
xlabel('Current private debt ($B$)','Interpreter','Latex')
Hlegend=legend('End of period private debt ($b''$)','Private debt limit','45 degree','Location','southeast'); set(Hlegend,'Interpreter','Latex')
hold off;xlim([0 .6]);
set(gca, 'FontSize',15)
exportfig(gcf,'Plots\Fig6A_PVdebt_Policy_PVdebt.eps','color','cmyk','resolution',1600)
%% PRIVATE BORROWING AND TRANSFER
mean_ind=22;
bg=1;
shoc=25;
figure
Dlim=KAPYT./q_big;
mY=meanY;

%yyaxis left
plot(cte_debtfactor*BGgrid(:,1)/mY,squeeze(bp(bg,mean_ind,shoc,:))/mY,'Linewidth',2,'Color','b','LineStyle','-'); hold on;
plot(cte_debtfactor*BGgrid(:,1)/mY,squeeze(Dlim(bg,mean_ind,shoc,:))/mY,'Linewidth',2,'Color','k','LineStyle',':'); hold on;
ylim([0 .5]);
ylabel('Percent of output','Interpreter','Latex'); legend boxoff;
%yyaxis right
plot(cte_debtfactor*BGgrid(:,1)/mY,squeeze(Transfer(bg,mean_ind,shoc,:))/mY,'Linewidth',2,'Color','r','LineStyle','--'); hold on;
%ylabel('Transfer (% output)'); legend boxoff;
xlabel('End of period public debt ($L''$)','Interpreter','Latex')
Hlegend=legend('Private debt ($b''$) ','Private debt limit','Fiscal transfer','Location','west'); set(Hlegend,'Interpreter','Latex')
hold off;xlim([0 .3]);
set(gca, 'FontSize',15)
exportfig(gcf,'Plots\Fig6B_PVdebt_Policy_PubNext.eps','color','cmyk','resolution',1600)
